package com.atguigu.spzx.manager.mapper;

import com.atguigu.spzx.model.vo.address.addressVo;
import org.apache.ibatis.annotations.*;
import com.atguigu.spzx.model.dto.address.useraddressDto;


import java.util.List;

@Mapper
public interface AddressMapper {
    @Select("Select id, recipient, phone, address from useraddress where userId=#{id}")
    List<addressVo> getAddressByid(Long id);

    @Delete("DELETE FROM useraddress WHERE id = #{id}")
    void deleteAddressByid(Long id);

    @Update("update useraddress set recipient = " +
            "#{recipient},phone = #{phone}, address = #{address},updateTime =NOW() where id = #{id}")
    void alterAddressByid(useraddressDto useraddressDto);

    @Insert("insert into useraddress(userId,recipient,phone,address,createTime,updateTime) " +
            "values (#{userId},#{recipient},#{phone},#{address},NOW(),NOW())")
    void saveAddress(useraddressDto useraddressDto);
}
